home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12962 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: in-news.erinet.com!usenet
  2. From: timb@erinet.com (Tim Berens)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Settle a bet please
  5. Date: Wed, 03 Apr 1996 22:03:45 GMT
  6. Organization: EriNet Online 513 436-9915
  7. Message-ID: <4jufbc$erj@eri.erinet.com>
  8. References: <4jfopb$o9n@news1.sympatico.ca> <4jh8rtINNosd@mayne.ugrad.cs.ubc.ca> <4jp8li$ue@eri2.erinet.com> <828542716snz@genesis.demon.co.uk>
  9. NNTP-Posting-Host: edlp162.erinet.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Lawrence Kirby <fred@genesis.demon.co.uk> wrote:
  13.  
  14. >In article <4jp8li$ue@eri2.erinet.com> timb@erinet.com "Tim Berens" writes:
  15.  
  16. >>Here's an interesting way to decide for yourselves:
  17. >>
  18. >>main()
  19. >>{
  20. >>    printf("size is: %d",sizeof("My Name"));
  21. >>}
  22.  
  23. >Better make that:
  24.  
  25. >     printf("size is: %d",(int)sizeof("My Name"));
  26.  
  27. >I'll hazard a guess that sizeof("My Name") fits in an int. :-)
  28.  
  29. >>This will display how many bytes your compiler thinks should be
  30. >>allocated for "My Name"
  31.  
  32. >Remember sizeof doesn't produce a result of type int, rather size_t which
  33. >is some implementation-dependent unsigned type.
  34.  
  35. >-- 
  36. >-----------------------------------------
  37. >Lawrence Kirby | fred@genesis.demon.co.uk
  38. >Wilts, England | 70734.126@compuserve.com
  39. >-----------------------------------------
  40.  
  41.  
  42. Do people participate in this newsgroup simply to show their smarts by
  43. desperately seeking nits to pick?  
  44.  
  45. Also, even though it is remotely possible that size_t is not the same
  46. size as an int and that the compiler may not automatically cast it to
  47. an int for the function call Or that the size of "My name" will exceed
  48. 32K and size_t will be a 2 byte unsigned integer, does it really
  49. matter in this example?  Can you name a compiler where
  50. printf("size=%d",sizeof("My Name"));  will not properly display
  51. "size=8"?
  52.  
  53.  
  54.  
  55.  
  56.  
  57.